package com.nuo.backend.modules.security.controller;

import java.util.Arrays;
import java.util.Map;

import com.nuo.backend.common.annotation.SysLog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.nuo.backend.modules.security.entity.SecConfigEntity;
import com.nuo.backend.modules.security.service.SecConfigService;
import com.nuo.backend.common.utils.PageUtils;
import com.nuo.backend.common.utils.R;



/**
 * 系统配置信息表
 *
 * @author nuo
 * @email 3033616351@qq.com
 * @date 2022-12-04 01:55:55
 */
@RestController
@RequestMapping("sec/config")
public class SecConfigController {

    @Autowired
    private SecConfigService secConfigService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = secConfigService.queryPage(params);
        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Long id){
        return R.ok().put("sysConfig", secConfigService.getById(id));
    }

    /**
     * 保存
     */
    @SysLog("保存配置")
    @RequestMapping("/save")
    public R save(@RequestBody SecConfigEntity secConfig){
		secConfigService.save(secConfig);
        return R.ok();
    }

    /**
     * 修改
     */
    @SysLog("修改配置")
    @RequestMapping("/update")
    public R update(@RequestBody SecConfigEntity secConfig){
		secConfigService.updateById(secConfig);
        return R.ok();
    }

    /**
     * 删除
     */
    @SysLog("删除配置")
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] ids){
		secConfigService.removeByIds(Arrays.asList(ids));
        return R.ok();
    }

}
